//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a sample for BCGControlBar Library Professional Edition
// Copyright (C) 1998-2014 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions 
// of the accompanying license agreement.
//*******************************************************************************
//
// FilterBarGridCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "FilterBarGridCtrl.h"
#include "ImportDataCheckPropPage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//----------
// Demo data
//----------

#define DRIVERS_NUM	46
LPCTSTR arDrivers [DRIVERS_NUM] =
{
	_T("Antonio Moreno"),
	_T("Annette Roulet"),
	_T("Thomas Hardy"),
	_T("Frederique Citeaux"),
	_T("Martin Sommer"),
	_T("Laurence Lebihan"),
	_T("Victoria Ashworth"),
	_T("Aria Cruz"),
	_T("Patricio Simpson"),
	_T("Francisco Chang"),
	_T("Yang Wang"),
	_T("Pedro Afonso"),
	_T("Patricia McKenna"),
	_T("Sven Ottlieb"),
	_T("Roland Mendel"),
	_T("Diego Roel"),
	_T("Martine Rance"),
	_T("Carine Schmitt"),
	_T("Paolo Accorti"),
	_T("Peter Franken"),
	_T("Eduardo Saavedra"),
	_T("Jose Pedro Freyre"),
	_T("Andre Fonseca"),
	_T("Howard Snyder"),
	_T("Manuel Pereira"),
	_T("Mario Pontes"),
	_T("Carlos Hernandez"),
	_T("Yoshi Latimer"),
	_T("Philip Cramer"),
	_T("Daniel Tonini"),
	_T("John Steel"),
	_T("Renate Messner"),
	_T("Jaime Yorres"),
	_T("Carlos Gonzalez"),
	_T("Felipe Izquierdo"),
	_T("Catherine Dewey"),
	_T("Frank Wilson"),
	_T("Giovanni Rovelli"),
	_T("Jean Fresniere"),
	_T("Alexander Feuer"),
	_T("Simon Crowther"),
	_T("Yvonne Moncada"),
	_T("Rene Phillips"),
	_T("Henriette Pfalzheim"),
	_T("Guillermo Fernandez"),
	_T("Georg Pipps"),
};

#define CARTYPE_NUM	5
LPCTSTR arCarType [CARTYPE_NUM] =
{
	_T("Passenger Car"),
	_T("Truck"),
	_T("Van"),
	_T("SUV"),
	_T("Bus"),
};

typedef struct {
	int min; 
	int max;
} PASSENGERS;
PASSENGERS arPassengers [CARTYPE_NUM] =
{
	{2, 5},
	{2, 3},
	{8, 21},
	{2, 8},
	{30, 60},
};

#define COLOR_NUM	7
LPCTSTR arColor [COLOR_NUM] =
{
	_T("black"),
	_T("white"),
	_T("red"),
	_T("green"),
	_T("blue"),
	_T("silver"),
	_T("yellow"),
};

/////////////////////////////////////////////////////////////////////////////
// CFilterBarGridCtrl

IMPLEMENT_DYNCREATE(CFilterBarGridCtrl, CBCGPGridCtrl)

CFilterBarGridCtrl::CFilterBarGridCtrl()
{
}

CFilterBarGridCtrl::~CFilterBarGridCtrl()
{
}


BEGIN_MESSAGE_MAP(CFilterBarGridCtrl, CBCGPGridCtrl)
	//{{AFX_MSG_MAP(CFilterBarGridCtrl)
	ON_WM_CREATE()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
	ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnNeedTipText)
END_MESSAGE_MAP()

int CFilterBarGridCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CBCGPGridCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	//--------------------------
	// Set grid general options:
	//--------------------------
	EnableMarkSortedColumn (TRUE, FALSE);
	EnableHeader (TRUE, BCGP_GRID_HEADER_MOVE_ITEMS | BCGP_GRID_HEADER_SORT);
	EnableRowHeader (TRUE);
	SetReadOnly ();
	EnableInvertSelOnCtrl ();
	SetRowHeaderWidth(50);

	ShowWindow(SW_SHOW);

	return 0;
}

//********************************************************************************
void CFilterBarGridCtrl::OnDestroy() 
{
	SaveState (_T("FilterBarGrid"));
	CBCGPGridCtrl::OnDestroy();
}
//********************************************************************************
BOOL CFilterBarGridCtrl::IsItemFilteredByFilterBar (CBCGPGridItem* pItem, int nColumn, const CString& strFilter)
{
	return CBCGPGridCtrl::IsItemFilteredByFilterBar (pItem, nColumn, strFilter);
}